package com.player.thirdGroup.service;

import com.player.thirdGroup.dao.RoleDao;
import com.player.thirdGroup.entity.Role;
import com.player.thirdGroup.entity.User;
import com.player.thirdGroup.util.BootStrapTablePage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.UUID;

/**
 * @ClassName RoleService
 * @Description: TODO
 * @Author ForeverLoveT
 * @Date 2019/12/29 19:26
 * @Version V1.0
 **/
@Service
public class RoleService  {
    @Autowired
    private RoleDao roleDao;
    //全部列表 分页
    public List<Role> findAll(){

        return roleDao.findAll();
    }
    //修改状态
    public void updateStatus(String roleid,String rolestatus){
        Role role = roleDao.findById(roleid).get();
        if (rolestatus.equals("0")){
            role.setRolestatus("1");
        }
        if(rolestatus.equals("1")){
            role.setRolestatus("0");
        }
        roleDao.save(role);
    }
/**
 * @MethodName: roleAdd
 * @Description: TODO
 * @Param: [role]
 * @Return: void
 * @Author: ForeverLoveT
 * @Date: 10:57
**/

    public void roleAdd(Role role) {
        role.setRoleid(UUID.randomUUID().toString());
        roleDao.save(role);

    }
    //回显
    public Role findByid(String id) {
        return roleDao.findById(id).get();
    }
    //修改
    public void update(Role role) {
        roleDao.save(role);
    }
}
